package com.empire.module.member.dal.mysql.mappolygonpoint;

import java.util.*;

import com.empire.framework.common.pojo.PageResult;
import com.empire.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.empire.framework.mybatis.core.mapper.BaseMapperX;
import com.empire.module.member.dal.dataobject.mappolygonpoint.MapPolygonPointDO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.empire.module.member.controller.admin.mappolygonpoint.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 多边形顶点坐标 Mapper
 *
 * @author 主席大人
 */
@Mapper
public interface MapPolygonPointMapper extends BaseMapperX<MapPolygonPointDO> {

    default PageResult<MapPolygonPointDO> selectPage(MapPolygonPointPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MapPolygonPointDO>()
                .eqIfPresent(MapPolygonPointDO::getPolygonId, reqVO.getPolygonId())
                .eqIfPresent(MapPolygonPointDO::getRingIndex, reqVO.getRingIndex())
                .eqIfPresent(MapPolygonPointDO::getLng, reqVO.getLng())
                .eqIfPresent(MapPolygonPointDO::getLat, reqVO.getLat())
                .eqIfPresent(MapPolygonPointDO::getPointIndex, reqVO.getPointIndex())
                .orderByDesc(MapPolygonPointDO::getId));
    }

    // 根据多边形ID删除顶点
    @Delete("delete from member_map_polygon_point where polygon_id = #{polygonId}")
    void deleteByPolygonId(@Param("polygonId") String polygonId);

    // 根据多边形ID查询顶点（按环和顺序排序）
    List<MapPolygonPointDO> selectByPolygonId(String polygonId);

    // 根据配置ID查询所有顶点（关联多边形）
    List<MapPolygonPointDO> selectByConfigId(String configId);

}